#ifndef __BHTTP_BREQUEST_H__
#define __BHTTP_BREQUEST_H__
#pragma once

#include <string>
#include <vector>
#include <memory>
#include <functional>

namespace bhttp
{
struct formpart
{
	std::string name;
	std::string data;
	std::string ctype;
	std::string fname;
	std::string fpath;
};

class brequest
{
public:
	enum class type
	{
		GET,
		POST,
		DEL,
        PUT,
        PATCH,
		UNKNOWN
	};

	explicit brequest(brequest::type tp = brequest::type::GET);
	~brequest();

	void method(const brequest::type tp);
	const brequest::type method() const;

	void url(const std::string& url);
	void url(std::string&& url);
	const char* url() const;

	void body(const char* buffer, size_t len);
	void body(const std::string& str);
	const char* body() const;
	size_t body_size() const;

	void headers(const std::vector<std::string>& hds);
	void headers(std::vector<std::string>&& hds);
	const std::vector<std::string> headers() const;
    void header(const std::string& key, const std::string& value);
    std::string header(const std::string& key);

	void form(const formpart& fm);
	void form(formpart&& fm);
	void forms(const std::vector<formpart>& fms);
	void forms(std::vector<formpart>&& fms);
	const std::vector<formpart> forms() const;

private:
	brequest::type method_{ brequest::type::UNKNOWN };
	std::string	url_;
	std::vector<char> body_;
	std::vector<std::string> headers_;
	std::vector<formpart> forms_;
};

}
#endif //__BHTTP_REQUEST_H__
